package com.lxk.service.impl;

import com.lxk.dao.AboutUsMapper;
import com.lxk.dao.RuleInfoMapper;
import com.lxk.pojo.AboutUs;
import com.lxk.pojo.RuleInfo;
import com.lxk.service.TextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author JohnSoybean
 * @create 2020/4/8 12:10
 * @description
 */
@Service
@Transactional
public class TextServiceImpl implements TextService {

    @Autowired
    private RuleInfoMapper rim;
    @Autowired
    private AboutUsMapper aum;

    public String showRuleText(Integer ruleInfoId) {
        RuleInfo ruleInfo = rim.selectByPrimaryKey(ruleInfoId);
        return ruleInfo.getRuleInfoText();
    }

    public String showAboutUs() {
        AboutUs aboutUs = aum.selectByPrimaryKey(1);
        return aboutUs.getAboutUsContent();
    }

    public void editRuleText(Integer ruleInfoId, String text) {
        RuleInfo ruleInfo = rim.selectByPrimaryKey(ruleInfoId);
        ruleInfo.setRuleInfoText(text);
        rim.updateByPrimaryKeyWithBLOBs(ruleInfo);
    }

    public void editAboutUs(String text) {
        AboutUs aboutUs = aum.selectByPrimaryKey(1);
        aboutUs.setAboutUsContent(text);
        aum.updateByPrimaryKeyWithBLOBs(aboutUs);
    }
}
